using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class so_ProductionItemsMap : EntityTypeConfiguration<so_ProductionItems>
    {
        public so_ProductionItemsMap()
        {
            // Primary Key
            this.HasKey(t => new { t.Sale_Order, t.Sales_Item, t.Description, t.Production, t.Sales_Item_Id, t.Work_Order });

            // Properties
            this.Property(t => t.Sale_Order)
                .IsRequired()
                .HasMaxLength(8);

            this.Property(t => t.Sales_Item)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.Description)
                .IsRequired()
                .HasMaxLength(250);

            this.Property(t => t.Production)
                .IsRequired()
                .HasMaxLength(3);

            this.Property(t => t.Sales_Item_Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("so_ProductionItems");
            this.Property(t => t.Sale_Order).HasColumnName("Sale_Order");
            this.Property(t => t.Sales_Item).HasColumnName("Sales_Item");
            this.Property(t => t.Description).HasColumnName("Description");
            this.Property(t => t.Quantity).HasColumnName("Quantity");
            this.Property(t => t.Discount).HasColumnName("Discount");
            this.Property(t => t.Unit_Price).HasColumnName("Unit_Price");
            this.Property(t => t.VAT).HasColumnName("VAT");
            this.Property(t => t.Production).HasColumnName("Production");
            this.Property(t => t.Sales_Item_Id).HasColumnName("Sales_Item_Id");
            this.Property(t => t.Work_Order).HasColumnName("Work_Order");
        }
    }
}
